package com.xy.smartsms.helper;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.xy.smartsms.facade.SmsProcessFacade;
import com.xy.smartsms.presenter.BubblePresenter;

/**
 * Created by admin on 2017/8/28 0028.
 */

public class SmartSmsCacheHelper {
    private WorkHandler mWorkHandler = new WorkHandler();

    private class WorkHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
        }
    }

    public void loadBubble(String phoneNumber) {
        SmsProcessFacade.getInstance().loadCache(phoneNumber);
    }

    public void clearBubble(Context context, String phoneNumber) {
        BubblePresenter.clearCache();
        //TODO DuoquBubbleViewManager.clearCacheData(context);
        if (SmsProcessFacade.getInstance() != null) {
            SmsProcessFacade.getInstance().clearCache(phoneNumber);
        }
    }

    public void parseBubble(String phoneNum, int limit) {
        SmsProcessFacade.getInstance().backgroundParse(phoneNum, limit);
    }

    private static SmartSmsCacheHelper sCacheHelper = null;

    public static SmartSmsCacheHelper getInstance() {
        synchronized (SmartSmsCacheHelper.class) {
            if (sCacheHelper == null) {
                sCacheHelper = new SmartSmsCacheHelper();
            }
        }

        return sCacheHelper;
    }
}
